package cn.web.servlet;

import cn.service.Userservice;
import cn.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/deleteUserServlet")
public class DeleteUserServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        if(!id.equals("1")) {
            Userservice userservice = new UserServiceImpl();
            userservice.deleteUser(id);
            response.sendRedirect(request.getContextPath() + "/userListServlet");
        }else{
            System.out.println("管理员用户删不了");
            request.setAttribute("login_respon","管理员你™还敢删？");
            request.getRequestDispatcher("/login.jsp").forward(request, response);
        }

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
